<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>RF22: RF22Router Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />



</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">RF22
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a>  </div>
  <div class="headertitle">
<div class="title">RF22Router Class Reference</div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="RF22Router" --><!-- doxytag: inherits="RF22ReliableDatagram" -->
<p><a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a> subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a network.  
 <a href="classRF22Router.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="RF22Router_8h_source.html">RF22Router.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for RF22Router:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classRF22Router.png" usemap="#RF22Router_map" alt=""/>
  <map id="RF22Router_map" name="RF22Router_map">
<area href="classRF22ReliableDatagram.html" title="RF22 subclass for sending addressed, acknowledged, retransmitted datagrams." alt="RF22ReliableDatagram" shape="rect" coords="0,112,141,136"/>
<area href="classRF22Datagram.html" title="RF22 subclass for addressed, unreliable messages." alt="RF22Datagram" shape="rect" coords="0,56,141,80"/>
<area href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams." alt="RF22" shape="rect" coords="0,0,141,24"/>
<area href="classRF22Mesh.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw..." alt="RF22Mesh" shape="rect" coords="0,224,141,248"/>
</map>
 </div></div>

<p><a href="classRF22Router-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structRF22Router_1_1RoutedMessage.html">RoutedMessage</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Defines the structure of a <a class="el" href="classRF22Router.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw...">RF22Router</a> message.  <a href="structRF22Router_1_1RoutedMessage.html#details">More...</a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structRF22Router_1_1RoutedMessageHeader.html">RoutedMessageHeader</a></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structRF22Router_1_1RoutingTableEntry.html">RoutingTableEntry</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Defines an entry in the routing table.  <a href="structRF22Router_1_1RoutingTableEntry.html#details">More...</a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Router.html#a415a311041d63a34c1d055c706cf872f">RouteState</a> { <a class="el" href="classRF22Router.html#a415a311041d63a34c1d055c706cf872fa9d8af0e15d87751008004e31b3db1d80">Invalid</a> =  0, 
<a class="el" href="classRF22Router.html#a415a311041d63a34c1d055c706cf872fa7f5766dd7d24e2607d7d7d8d7afc246b">Discovering</a>, 
<a class="el" href="classRF22Router.html#a415a311041d63a34c1d055c706cf872fad754c46fbf5c01d1c70eef6a05987109">Valid</a>
 }</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Values for the possible states for routes.  <a href="classRF22Router.html#a415a311041d63a34c1d055c706cf872f">More...</a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Router.html#a5e934a0ccc2d764ef0c0aa70a3d32cf9">RF22Router</a> (uint8_t thisAddress=0, uint8_t slaveSelectPin=10, uint8_t interrupt=0)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">boolean&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Router.html#ac6037c3300511d0277e42edea8ccf873">init</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Router.html#a05f3bc34b320c05af36ad0f0f927bfa0">setMaxHops</a> (uint8_t max_hops)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Router.html#aa212a84ed49696f208e513dfbc87813e">addRouteTo</a> (uint8_t dest, uint8_t next_hop, uint8_t state=Valid)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="structRF22Router_1_1RoutingTableEntry.html">RoutingTableEntry</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Router.html#a33862cdecebe61b34ee93567db3c673b">getRouteTo</a> (uint8_t dest)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">boolean&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Router.html#a012322d33591b95adde3a206dd618ffe">deleteRouteTo</a> (uint8_t dest)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Router.html#a63c6746df7f09ec825760bebb1581cb4">retireOldestRoute</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Router.html#aaabe7e6d549d3f41e8071f1952b847d3">clearRoutingTable</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Router.html#adb03b403f981659ea55e90867741d085">sendtoWait</a> (uint8_t *buf, uint8_t len, uint8_t dest)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Router.html#a43192f80e7d8f05844807b07f7d7bdf0">sendtoWait</a> (uint8_t *buf, uint8_t len, uint8_t dest, uint8_t source)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">boolean&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Router.html#abbb4344322693607d8a0be5f0f831015">recvfromAck</a> (uint8_t *buf, uint8_t *len, uint8_t *source=NULL, uint8_t *dest=NULL, uint8_t *id=NULL, uint8_t *flags=NULL)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">boolean&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Router.html#af4f975c229288c480e13de4e6ddea8fb">recvfromAckTimeout</a> (uint8_t *buf, uint8_t *len, uint16_t timeout, uint8_t *source=NULL, uint8_t *dest=NULL, uint8_t *id=NULL, uint8_t *flags=NULL)</td></tr>
<tr><td colspan="2"><h2><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Router.html#a1ddc1e959c8851add1c78ee1b1af8b66">peekAtMessage</a> (<a class="el" href="structRF22Router_1_1RoutedMessage.html">RoutedMessage</a> *message, uint8_t messageLen)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Router.html#a76edfc892808e5b8c1d54f69ba2d8ebd">route</a> (<a class="el" href="structRF22Router_1_1RoutedMessage.html">RoutedMessage</a> *message, uint8_t messageLen)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Router.html#ac8bf56e995cbf6e51104f888496751a8">deleteRoute</a> (uint8_t index)</td></tr>
<tr><td colspan="2"><h2><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Router.html#a27591173bc7e622beae9c247634b3dec">_lastE2ESequenceNumber</a></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRF22Router.html#ab6af5059286ee412f81f33c67ac95132">_max_hops</a></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p><a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a> subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a network. </p>
<p>Extends <a class="el" href="classRF22ReliableDatagram.html" title="RF22 subclass for sending addressed, acknowledged, retransmitted datagrams.">RF22ReliableDatagram</a> to define addressed messages That are reliably transmitted and routed across a network. Each message is transmitted reliably between each hop in order to get from the source node to the destination node.</p>
<p>With <a class="el" href="classRF22Router.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw...">RF22Router</a>, routes are hard wired. This means that each node must have programmed in it how to reach each of the other nodes it will be trying to communicate with. This means you must specify the next-hop node address for each of the destination nodes, using the <a class="el" href="classRF22Router.html#aa212a84ed49696f208e513dfbc87813e">addRouteTo()</a> function.</p>
<p>When <a class="el" href="classRF22Router.html#adb03b403f981659ea55e90867741d085">sendtoWait()</a> is called with a new message to deliver, and the destination address, <a class="el" href="classRF22Router.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw...">RF22Router</a> looks up the next hop node for the destination node. It then uses <a class="el" href="classRF22ReliableDatagram.html" title="RF22 subclass for sending addressed, acknowledged, retransmitted datagrams.">RF22ReliableDatagram</a> to (reliably) deliver the message to the next hop (which is expected also to be running an <a class="el" href="classRF22Router.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw...">RF22Router</a>). If that next-hop node is not the final destination, it will also look up the next hop for the destination node and (reliably) deliver the message to the next hop. By this method, messages can be delivered across a network of nodes, even if each node cannot hear all of the others in the network. Each time a message is received for another node and retransmitted to the next hop, the HOPS filed in teh header is incremented. If a message is received for routing to another node which has exceed the routers max_hops, the message wioll be dropped and ignored. This helps prevent infinite routing loops.</p>
<p><a class="el" href="classRF22Router.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw...">RF22Router</a> supports messages with a dest of RF22_BROADCAST_ADDRESS. Such messages are not routed, and are broadcast (once) to all nodes within range.</p>
<p>The <a class="el" href="classRF22Router.html#abbb4344322693607d8a0be5f0f831015">recvfromAck()</a> function is responsible not just for receiving and delivering messages addressed to this node (or RF22_BROADCAST_ADDRESS), but it is also responsible for routing other message to their next hop. This means that it is important to call <a class="el" href="classRF22Router.html#abbb4344322693607d8a0be5f0f831015">recvfromAck()</a> or <a class="el" href="classRF22Router.html#af4f975c229288c480e13de4e6ddea8fb">recvfromAckTimeout()</a> frequently in your main loop. <a class="el" href="classRF22Router.html#abbb4344322693607d8a0be5f0f831015">recvfromAck()</a> will return false if it receives a message but it is not for this node.</p>
<p><a class="el" href="classRF22Router.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw...">RF22Router</a> does not provide reliable end-to-end delivery, but uses reliable hop-to-hop delivery. If a message is unable to be delivered to an end node during to a delivery failure between 2 hops, the source node will not be told about it.</p>
<p>Note: This class is most useful for networks of nodes that are essentially static (i.e. the nodes dont move around), and for which the routing never changes. If that is not the case for your proposed network, see <a class="el" href="classRF22Mesh.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw...">RF22Mesh</a> instead.</p>
<dl class="user"><dt><b>The Routing Table</b></dt><dd></dd></dl>
<p>The routing table is a local table in <a class="el" href="classRF22Router.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw...">RF22Router</a> that holds the information about the next hop node address for each destination address you may want to send a message to. It is your responsibility to make sure every node in an <a class="el" href="classRF22Router.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw...">RF22Router</a> network has been configured with a unique address and the routing information so that messages are correctly routed across the network from source node to destination node. This is usually done once in setup() by calling <a class="el" href="classRF22Router.html#aa212a84ed49696f208e513dfbc87813e">addRouteTo()</a>. The hardwired routing will in general be different on each node, and will depend on the physical topololgy of the network. You can also use <a class="el" href="classRF22Router.html#aa212a84ed49696f208e513dfbc87813e">addRouteTo()</a> to change a route and <a class="el" href="classRF22Router.html#a012322d33591b95adde3a206dd618ffe">deleteRouteTo()</a> to delete a route at run time. Youcan also clear the entire routing table</p>
<p>The Routing Table has limited capacity for entries (defined by RF22_ROUTING_TABLE_SIZE, which is 10) if more than RF22_ROUTING_TABLE_SIZE are added, the oldest (first) one will be removed by calling <a class="el" href="classRF22Router.html#a63c6746df7f09ec825760bebb1581cb4">retireOldestRoute()</a></p>
<dl class="user"><dt><b>Message Format</b></dt><dd></dd></dl>
<p><a class="el" href="classRF22Router.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw...">RF22Router</a> add to the lower level <a class="el" href="classRF22ReliableDatagram.html" title="RF22 subclass for sending addressed, acknowledged, retransmitted datagrams.">RF22ReliableDatagram</a> (and even lower level <a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a>) class mesage formats. In those lower level classes, the hop-to-hop message headers are in the <a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a> message headers, and are handled automcatically by tyhe <a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a> hardware. <a class="el" href="classRF22Router.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw...">RF22Router</a> and its subclasses add an end-to-end addressing header in the payload of the <a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a> message, and before the <a class="el" href="classRF22Router.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw...">RF22Router</a> application data.</p>
<ul>
<li>1 octet DEST, the destination node address (ie the address of the final destination node for this message)</li>
<li>1 octet SOURCE, the source node address (ie the address of the originating node that first sent the message).</li>
<li>1 octet HOPS, the number of hops this message has traversed so far.</li>
<li>1 octet ID, an incrementing message ID for end-to-end message tracking for use by subclasses. Not used by <a class="el" href="classRF22Router.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw...">RF22Router</a>.</li>
<li>1 octet FLAGS, a bitmask for use by subclasses. Not used by <a class="el" href="classRF22Router.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw...">RF22Router</a>.</li>
<li>0 or more octets DATA, the application payload data. The length of this data is implicit in the length of the entire message.</li>
</ul>
<p>You should be careful to note that there are ID and FLAGS fields in the low level per-hop message header too. These are used only for hop-to-hop, and in general will be different to the ones at the <a class="el" href="classRF22Router.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw...">RF22Router</a> level.</p>
<dl class="user"><dt><b>Testing</b></dt><dd></dd></dl>
<p>Bench testing of such networks is notoriously difficult, especially simulating limited radio connectivity between some nodes. To assist testing (both during <a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a> development and for your own networks) RF22Router.cpp has the ability to simulate a number of different small network topologies. Each simulated network supports 4 nodes with addresses 1 to 4. It operates by pretending to not hear <a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a> messages from certain other nodes. You can enable testing with a #define TEST_NETWORK in <a class="el" href="RF22Router_8h_source.html">RF22Router.h</a> The sample programs rf22_mesh_* rely on this feature.</p>
<p>Part of the Arduino <a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a> library for operating with HopeRF <a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a> compatible transceivers (see <a href="http://www.hoperf.com">http://www.hoperf.com</a>) </p>
</div><hr/><h2>Member Enumeration Documentation</h2>
<a class="anchor" id="a415a311041d63a34c1d055c706cf872f"></a><!-- doxytag: member="RF22Router::RouteState" ref="a415a311041d63a34c1d055c706cf872f" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="classRF22Router.html#a415a311041d63a34c1d055c706cf872f">RF22Router::RouteState</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Values for the possible states for routes. </p>
<dl><dt><b>Enumerator: </b></dt><dd><table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><em><a class="anchor" id="a415a311041d63a34c1d055c706cf872fa9d8af0e15d87751008004e31b3db1d80"></a><!-- doxytag: member="Invalid" ref="a415a311041d63a34c1d055c706cf872fa9d8af0e15d87751008004e31b3db1d80" args="" -->Invalid</em>&nbsp;</td><td>
<p>No valid route is known. </p>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="a415a311041d63a34c1d055c706cf872fa7f5766dd7d24e2607d7d7d8d7afc246b"></a><!-- doxytag: member="Discovering" ref="a415a311041d63a34c1d055c706cf872fa7f5766dd7d24e2607d7d7d8d7afc246b" args="" -->Discovering</em>&nbsp;</td><td>
<p>Discovering a route (not currently used) </p>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="a415a311041d63a34c1d055c706cf872fad754c46fbf5c01d1c70eef6a05987109"></a><!-- doxytag: member="Valid" ref="a415a311041d63a34c1d055c706cf872fad754c46fbf5c01d1c70eef6a05987109" args="" -->Valid</em>&nbsp;</td><td>
<p>Route is valid. </p>
</td></tr>
</table>
</dd>
</dl>

</div>
</div>
<hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a5e934a0ccc2d764ef0c0aa70a3d32cf9"></a><!-- doxytag: member="RF22Router::RF22Router" ref="a5e934a0ccc2d764ef0c0aa70a3d32cf9" args="(uint8_t thisAddress=0, uint8_t slaveSelectPin=10, uint8_t interrupt=0)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">RF22Router::RF22Router </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>thisAddress</em> = <code>0</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>slaveSelectPin</em> = <code>10</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>interrupt</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Constructor. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">thisAddress</td><td>The address to assign to this node. Defaults to 0 </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">slaveSelectPin</td><td>the Arduino pin number of the output to use to select the <a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a> before accessing it </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">interrupt</td><td>The interrupt number to use. Default is interrupt 0 (Arduino input pin 2) </td></tr>
  </table>
  </dd>
</dl>

<p>References <a class="el" href="classRF22Router.html#ab6af5059286ee412f81f33c67ac95132">_max_hops</a>, and <a class="el" href="classRF22Router.html#aaabe7e6d549d3f41e8071f1952b847d3">clearRoutingTable()</a>.</p>

</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="aa212a84ed49696f208e513dfbc87813e"></a><!-- doxytag: member="RF22Router::addRouteTo" ref="aa212a84ed49696f208e513dfbc87813e" args="(uint8_t dest, uint8_t next_hop, uint8_t state=Valid)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void RF22Router::addRouteTo </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>dest</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>next_hop</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>state</em> = <code>Valid</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Adds a route to the local routing table, or updates it if already present. If there is not enough room the oldest (first) route will be deleted by calling <a class="el" href="classRF22Router.html#a63c6746df7f09ec825760bebb1581cb4">retireOldestRoute()</a>. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">dest</td><td>The destination node address. RF22_BROADCAST_ADDRESS is permitted. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">next_hop</td><td>The address of the next hop to send messages destined for dest </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">state</td><td>The satte of the route. Defaults to Valid </td></tr>
  </table>
  </dd>
</dl>

<p>References <a class="el" href="structRF22Router_1_1RoutingTableEntry.html#ae242ebbb95585705b02d1799bed18622">RF22Router::RoutingTableEntry::dest</a>, <a class="el" href="classRF22Router.html#a415a311041d63a34c1d055c706cf872fa9d8af0e15d87751008004e31b3db1d80">Invalid</a>, <a class="el" href="structRF22Router_1_1RoutingTableEntry.html#a304700b8d7f20371e53a1da2c6ab2c82">RF22Router::RoutingTableEntry::next_hop</a>, <a class="el" href="classRF22Router.html#a63c6746df7f09ec825760bebb1581cb4">retireOldestRoute()</a>, and <a class="el" href="structRF22Router_1_1RoutingTableEntry.html#a7f8fb79413e6690eacf387fa0d3512fb">RF22Router::RoutingTableEntry::state</a>.</p>

<p>Referenced by <a class="el" href="classRF22Mesh.html#a276fbdde9038cb38e3ba2d6cffa95a4c">RF22Mesh::doArp()</a>, <a class="el" href="classRF22Mesh.html#a340dba041b6d8e83a6ce6a4f613eb112">RF22Mesh::peekAtMessage()</a>, <a class="el" href="classRF22Mesh.html#a5702996188d7b3941a844fc4d39a6f57">RF22Mesh::recvfromAck()</a>, and <a class="el" href="classRF22Mesh.html#ae7a3ab2784aaf45ab2d47e5d9ce5b405">RF22Mesh::route()</a>.</p>

</div>
</div>
<a class="anchor" id="aaabe7e6d549d3f41e8071f1952b847d3"></a><!-- doxytag: member="RF22Router::clearRoutingTable" ref="aaabe7e6d549d3f41e8071f1952b847d3" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void RF22Router::clearRoutingTable </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Clears all entries from the local routing table </p>

<p>References <a class="el" href="classRF22Router.html#a415a311041d63a34c1d055c706cf872fa9d8af0e15d87751008004e31b3db1d80">Invalid</a>.</p>

<p>Referenced by <a class="el" href="classRF22Router.html#a5e934a0ccc2d764ef0c0aa70a3d32cf9">RF22Router()</a>.</p>

</div>
</div>
<a class="anchor" id="ac8bf56e995cbf6e51104f888496751a8"></a><!-- doxytag: member="RF22Router::deleteRoute" ref="ac8bf56e995cbf6e51104f888496751a8" args="(uint8_t index)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void RF22Router::deleteRoute </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>index</em></td><td>)</td>
          <td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Deletes a specific rout entry from therouting table </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">index</td><td>The 0 based index of the routing table entry to delete </td></tr>
  </table>
  </dd>
</dl>

<p>References <a class="el" href="classRF22Router.html#a415a311041d63a34c1d055c706cf872fa9d8af0e15d87751008004e31b3db1d80">Invalid</a>, and <a class="el" href="structRF22Router_1_1RoutingTableEntry.html#a7f8fb79413e6690eacf387fa0d3512fb">RF22Router::RoutingTableEntry::state</a>.</p>

<p>Referenced by <a class="el" href="classRF22Router.html#a012322d33591b95adde3a206dd618ffe">deleteRouteTo()</a>, and <a class="el" href="classRF22Router.html#a63c6746df7f09ec825760bebb1581cb4">retireOldestRoute()</a>.</p>

</div>
</div>
<a class="anchor" id="a012322d33591b95adde3a206dd618ffe"></a><!-- doxytag: member="RF22Router::deleteRouteTo" ref="a012322d33591b95adde3a206dd618ffe" args="(uint8_t dest)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">boolean RF22Router::deleteRouteTo </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>dest</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Deletes from the local routing table any route for the destination node. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">dest</td><td>The destination node address </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>true if the route was present </dd></dl>

<p>References <a class="el" href="classRF22Router.html#ac8bf56e995cbf6e51104f888496751a8">deleteRoute()</a>.</p>

<p>Referenced by <a class="el" href="classRF22Mesh.html#a340dba041b6d8e83a6ce6a4f613eb112">RF22Mesh::peekAtMessage()</a>, and <a class="el" href="classRF22Mesh.html#ae7a3ab2784aaf45ab2d47e5d9ce5b405">RF22Mesh::route()</a>.</p>

</div>
</div>
<a class="anchor" id="a33862cdecebe61b34ee93567db3c673b"></a><!-- doxytag: member="RF22Router::getRouteTo" ref="a33862cdecebe61b34ee93567db3c673b" args="(uint8_t dest)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structRF22Router_1_1RoutingTableEntry.html">RF22Router::RoutingTableEntry</a> * RF22Router::getRouteTo </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>dest</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Finds and returns a <a class="el" href="structRF22Router_1_1RoutingTableEntry.html" title="Defines an entry in the routing table.">RoutingTableEntry</a> for the given destination node </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">dest</td><td>The desired destination node address. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>pointer to a <a class="el" href="structRF22Router_1_1RoutingTableEntry.html" title="Defines an entry in the routing table.">RoutingTableEntry</a> for dest </dd></dl>

<p>References <a class="el" href="classRF22Router.html#a415a311041d63a34c1d055c706cf872fa9d8af0e15d87751008004e31b3db1d80">Invalid</a>.</p>

<p>Referenced by <a class="el" href="classRF22Router.html#a76edfc892808e5b8c1d54f69ba2d8ebd">route()</a>, and <a class="el" href="classRF22Mesh.html#ada9dcba842569c7f126fdb1d085753a5">RF22Mesh::sendtoWait()</a>.</p>

</div>
</div>
<a class="anchor" id="ac6037c3300511d0277e42edea8ccf873"></a><!-- doxytag: member="RF22Router::init" ref="ac6037c3300511d0277e42edea8ccf873" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">boolean RF22Router::init </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Initialises this instance and the radio module connected to it. Overrides the <a class="el" href="classRF22Router.html#ac6037c3300511d0277e42edea8ccf873">init()</a> function in <a class="el" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a>. Sets max_hops to the default of RF22_DEFAULT_MAX_HOPS (30) </p>

<p>Reimplemented from <a class="el" href="classRF22Datagram.html#a7e9eb654f8e8be094c5f2c0531218531">RF22Datagram</a>.</p>

<p>References <a class="el" href="classRF22Router.html#ab6af5059286ee412f81f33c67ac95132">_max_hops</a>.</p>

</div>
</div>
<a class="anchor" id="a1ddc1e959c8851add1c78ee1b1af8b66"></a><!-- doxytag: member="RF22Router::peekAtMessage" ref="a1ddc1e959c8851add1c78ee1b1af8b66" args="(RoutedMessage *message, uint8_t messageLen)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void RF22Router::peekAtMessage </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structRF22Router_1_1RoutedMessage.html">RoutedMessage</a> *&#160;</td>
          <td class="paramname"><em>message</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>messageLen</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Lets sublasses peek at messages going past before routing or local delivery. Called by <a class="el" href="classRF22Router.html#abbb4344322693607d8a0be5f0f831015">recvfromAck()</a> immediately after it gets the message from <a class="el" href="classRF22ReliableDatagram.html" title="RF22 subclass for sending addressed, acknowledged, retransmitted datagrams.">RF22ReliableDatagram</a> </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">message</td><td>Pointer to the <a class="el" href="classRF22Router.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw...">RF22Router</a> message that was received. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">messageLen</td><td>Length of message in octets </td></tr>
  </table>
  </dd>
</dl>

<p>Reimplemented in <a class="el" href="classRF22Mesh.html#a340dba041b6d8e83a6ce6a4f613eb112">RF22Mesh</a>.</p>

<p>Referenced by <a class="el" href="classRF22Router.html#abbb4344322693607d8a0be5f0f831015">recvfromAck()</a>.</p>

</div>
</div>
<a class="anchor" id="abbb4344322693607d8a0be5f0f831015"></a><!-- doxytag: member="RF22Router::recvfromAck" ref="abbb4344322693607d8a0be5f0f831015" args="(uint8_t *buf, uint8_t *len, uint8_t *source=NULL, uint8_t *dest=NULL, uint8_t *id=NULL, uint8_t *flags=NULL)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">boolean RF22Router::recvfromAck </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>buf</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>source</em> = <code>NULL</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>dest</em> = <code>NULL</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>id</em> = <code>NULL</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>flags</em> = <code>NULL</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Starts the receiver if it is not running already. If there is a valid message available for this node (or RF22_BROADCAST_ADDRESS), send an acknowledgement to the last hop address (blocking until this is complete), then copy the application message payload data to buf and return true else return false. If a message is copied, *len is set to the length.. If from is not NULL, the originator SOURCE address is placed in *source. If to is not NULL, the DEST address is placed in *dest. This might be this nodes address or RF22_BROADCAST_ADDRESS. This is the preferred function for getting messages addressed to this node. If the message is not a broadcast, acknowledge to the sender before returning. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">buf</td><td>Location to copy the received message </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">len</td><td>Available space in buf. Set to the actual number of octets copied. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">source</td><td>If present and not NULL, the referenced uint8_t will be set to the SOURCE address </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dest</td><td>If present and not NULL, the referenced uint8_t will be set to the DEST address </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">id</td><td>If present and not NULL, the referenced uint8_t will be set to the ID </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">flags</td><td>If present and not NULL, the referenced uint8_t will be set to the FLAGS (not just those addressed to this node). </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>true if a valid message was recvived for this node copied to buf </dd></dl>

<p>Reimplemented from <a class="el" href="classRF22ReliableDatagram.html#a49dbf986b90cac7f1476ec56a4beab38">RF22ReliableDatagram</a>.</p>

<p>Reimplemented in <a class="el" href="classRF22Mesh.html#a5702996188d7b3941a844fc4d39a6f57">RF22Mesh</a>.</p>

<p>References <a class="el" href="classRF22Router.html#ab6af5059286ee412f81f33c67ac95132">_max_hops</a>, <a class="el" href="classRF22Datagram.html#a831ccec7d05b864cc3618f9c21894f17">RF22Datagram::_thisAddress</a>, <a class="el" href="classRF22Router.html#a1ddc1e959c8851add1c78ee1b1af8b66">peekAtMessage()</a>, <a class="el" href="classRF22ReliableDatagram.html#a49dbf986b90cac7f1476ec56a4beab38">RF22ReliableDatagram::recvfromAck()</a>, and <a class="el" href="classRF22Router.html#a76edfc892808e5b8c1d54f69ba2d8ebd">route()</a>.</p>

<p>Referenced by <a class="el" href="classRF22Mesh.html#a276fbdde9038cb38e3ba2d6cffa95a4c">RF22Mesh::doArp()</a>, <a class="el" href="classRF22Mesh.html#a5702996188d7b3941a844fc4d39a6f57">RF22Mesh::recvfromAck()</a>, and <a class="el" href="classRF22Router.html#af4f975c229288c480e13de4e6ddea8fb">recvfromAckTimeout()</a>.</p>

</div>
</div>
<a class="anchor" id="af4f975c229288c480e13de4e6ddea8fb"></a><!-- doxytag: member="RF22Router::recvfromAckTimeout" ref="af4f975c229288c480e13de4e6ddea8fb" args="(uint8_t *buf, uint8_t *len, uint16_t timeout, uint8_t *source=NULL, uint8_t *dest=NULL, uint8_t *id=NULL, uint8_t *flags=NULL)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">boolean RF22Router::recvfromAckTimeout </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>buf</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>timeout</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>source</em> = <code>NULL</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>dest</em> = <code>NULL</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>id</em> = <code>NULL</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>flags</em> = <code>NULL</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Starts the receiver if it is not running already. Similar to <a class="el" href="classRF22Router.html#abbb4344322693607d8a0be5f0f831015">recvfromAck()</a>, this will block until either a valid message available for this node or the timeout expires. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">buf</td><td>Location to copy the received message </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">len</td><td>Available space in buf. Set to the actual number of octets copied. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">timeout</td><td>Maximum time to wait in milliseconds </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">source</td><td>If present and not NULL, the referenced uint8_t will be set to the SOURCE address </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dest</td><td>If present and not NULL, the referenced uint8_t will be set to the DEST address </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">id</td><td>If present and not NULL, the referenced uint8_t will be set to the ID </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">flags</td><td>If present and not NULL, the referenced uint8_t will be set to the FLAGS (not just those addressed to this node). </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>true if a valid message was copied to buf </dd></dl>

<p>Reimplemented from <a class="el" href="classRF22ReliableDatagram.html#a0327f5c2c296c483df90b1f52ec2d141">RF22ReliableDatagram</a>.</p>

<p>Reimplemented in <a class="el" href="classRF22Mesh.html#a09ff3e2f1481180881ead85c069fe547">RF22Mesh</a>.</p>

<p>References <a class="el" href="classRF22Router.html#abbb4344322693607d8a0be5f0f831015">recvfromAck()</a>.</p>

</div>
</div>
<a class="anchor" id="a63c6746df7f09ec825760bebb1581cb4"></a><!-- doxytag: member="RF22Router::retireOldestRoute" ref="a63c6746df7f09ec825760bebb1581cb4" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void RF22Router::retireOldestRoute </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Deletes the oldest (first) route from the local routing table </p>

<p>References <a class="el" href="classRF22Router.html#ac8bf56e995cbf6e51104f888496751a8">deleteRoute()</a>.</p>

<p>Referenced by <a class="el" href="classRF22Router.html#aa212a84ed49696f208e513dfbc87813e">addRouteTo()</a>.</p>

</div>
</div>
<a class="anchor" id="a76edfc892808e5b8c1d54f69ba2d8ebd"></a><!-- doxytag: member="RF22Router::route" ref="a76edfc892808e5b8c1d54f69ba2d8ebd" args="(RoutedMessage *message, uint8_t messageLen)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t RF22Router::route </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structRF22Router_1_1RoutedMessage.html">RoutedMessage</a> *&#160;</td>
          <td class="paramname"><em>message</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>messageLen</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Finds the next-hop route and sends the message via <a class="el" href="classRF22ReliableDatagram.html#a47e85bffb81a3acdff6d5f15ce7bb65e">RF22ReliableDatagram::sendtoWait()</a>. This is virtual, which lets subclasses override or intercept the <a class="el" href="classRF22Router.html#a76edfc892808e5b8c1d54f69ba2d8ebd">route()</a> function. Called by sendtoWait after the message header has been filled in. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">message</td><td>Pointer to the <a class="el" href="classRF22Router.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw...">RF22Router</a> message to be sent. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">messageLen</td><td>Length of message in octets </td></tr>
  </table>
  </dd>
</dl>

<p>Reimplemented in <a class="el" href="classRF22Mesh.html#ae7a3ab2784aaf45ab2d47e5d9ce5b405">RF22Mesh</a>.</p>

<p>References <a class="el" href="structRF22Router_1_1RoutedMessageHeader.html#ac87393d376d884f770ee65764911f216">RF22Router::RoutedMessageHeader::dest</a>, <a class="el" href="classRF22Router.html#a33862cdecebe61b34ee93567db3c673b">getRouteTo()</a>, <a class="el" href="structRF22Router_1_1RoutedMessage.html#a730465e2760dc904d3bbfd52bf2cd1f4">RF22Router::RoutedMessage::header</a>, <a class="el" href="structRF22Router_1_1RoutingTableEntry.html#a304700b8d7f20371e53a1da2c6ab2c82">RF22Router::RoutingTableEntry::next_hop</a>, and <a class="el" href="classRF22ReliableDatagram.html#a47e85bffb81a3acdff6d5f15ce7bb65e">RF22ReliableDatagram::sendtoWait()</a>.</p>

<p>Referenced by <a class="el" href="classRF22Router.html#abbb4344322693607d8a0be5f0f831015">recvfromAck()</a>, and <a class="el" href="classRF22Router.html#a43192f80e7d8f05844807b07f7d7bdf0">sendtoWait()</a>.</p>

</div>
</div>
<a class="anchor" id="adb03b403f981659ea55e90867741d085"></a><!-- doxytag: member="RF22Router::sendtoWait" ref="adb03b403f981659ea55e90867741d085" args="(uint8_t *buf, uint8_t len, uint8_t dest)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t RF22Router::sendtoWait </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>buf</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>dest</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Sends a message to the destination node. Initialises the <a class="el" href="classRF22Router.html" title="RF22 subclass for sending addressed, optionally acknowledged datagrams multi-hop routed across a netw...">RF22Router</a> message header (the SOURCE address is set to the address of this node, HOPS to 0) and calls <a class="el" href="classRF22Router.html#a76edfc892808e5b8c1d54f69ba2d8ebd">route()</a> which looks up in the routing table the next hop to deliver to and sends the message to the next hop. Waits for an acknowledgement from the next hop (but not from the destination node (if that is different). </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">buf</td><td>The application message data </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">len</td><td>Number of octets in the application message data. 0 is permitted </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dest</td><td>The destination node address </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The result code:<ul>
<li>RF22_ROUTER_ERROR_NONE Message was routed and deliverd to the next hop (not necessarily to the final dest address)</li>
<li>RF22_ROUTER_ERROR_NO_ROUTE There was no route for dest in the local routing table</li>
<li>RF22_ROUTER_ERROR_UNABLE_TO_DELIVER Noyt able to deliver to the next hop (usually because it dod not acknowledge due to being off the air or out of range </li>
</ul>
</dd></dl>

<p>Reimplemented from <a class="el" href="classRF22ReliableDatagram.html#a47e85bffb81a3acdff6d5f15ce7bb65e">RF22ReliableDatagram</a>.</p>

<p>Reimplemented in <a class="el" href="classRF22Mesh.html#ada9dcba842569c7f126fdb1d085753a5">RF22Mesh</a>.</p>

<p>References <a class="el" href="classRF22Datagram.html#a831ccec7d05b864cc3618f9c21894f17">RF22Datagram::_thisAddress</a>.</p>

</div>
</div>
<a class="anchor" id="a43192f80e7d8f05844807b07f7d7bdf0"></a><!-- doxytag: member="RF22Router::sendtoWait" ref="a43192f80e7d8f05844807b07f7d7bdf0" args="(uint8_t *buf, uint8_t len, uint8_t dest, uint8_t source)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t RF22Router::sendtoWait </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>buf</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>dest</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>source</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Similar to <a class="el" href="classRF22Router.html#adb03b403f981659ea55e90867741d085">sendtoWait()</a> above, but spoofs the source address. For internal use only during routing </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">buf</td><td>The application message data </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">len</td><td>Number of octets in the application message data. 0 is permitted </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dest</td><td>The destination node address </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">source</td><td>The (fake) originatong node address. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The result code:<ul>
<li>RF22_ROUTER_ERROR_NONE Message was routed and deliverd to the next hop (not necessarily to the final dest address)</li>
<li>RF22_ROUTER_ERROR_NO_ROUTE There was no route for dest in the local routing table</li>
<li>RF22_ROUTER_ERROR_UNABLE_TO_DELIVER Noyt able to deliver to the next hop (usually because it dod not acknowledge due to being off the air or out of range </li>
</ul>
</dd></dl>

<p>References <a class="el" href="classRF22Router.html#a27591173bc7e622beae9c247634b3dec">_lastE2ESequenceNumber</a>, <a class="el" href="structRF22Router_1_1RoutedMessage.html#a65c73cedebd25552a31c88aa4c6aa1f4">RF22Router::RoutedMessage::data</a>, <a class="el" href="structRF22Router_1_1RoutedMessageHeader.html#ac87393d376d884f770ee65764911f216">RF22Router::RoutedMessageHeader::dest</a>, <a class="el" href="structRF22Router_1_1RoutedMessageHeader.html#a958cb0cdf8d3731495590088ea448943">RF22Router::RoutedMessageHeader::flags</a>, <a class="el" href="structRF22Router_1_1RoutedMessage.html#a730465e2760dc904d3bbfd52bf2cd1f4">RF22Router::RoutedMessage::header</a>, <a class="el" href="structRF22Router_1_1RoutedMessageHeader.html#a4c28e31c2768c519a1f5e01808f0220d">RF22Router::RoutedMessageHeader::hops</a>, <a class="el" href="structRF22Router_1_1RoutedMessageHeader.html#a7849aef5380c9fd8f597fa1e4028563e">RF22Router::RoutedMessageHeader::id</a>, <a class="el" href="classRF22Router.html#a76edfc892808e5b8c1d54f69ba2d8ebd">route()</a>, and <a class="el" href="structRF22Router_1_1RoutedMessageHeader.html#a69f76048bb061a95aafdab043a6b5c7f">RF22Router::RoutedMessageHeader::source</a>.</p>

</div>
</div>
<a class="anchor" id="a05f3bc34b320c05af36ad0f0f927bfa0"></a><!-- doxytag: member="RF22Router::setMaxHops" ref="a05f3bc34b320c05af36ad0f0f927bfa0" args="(uint8_t max_hops)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void RF22Router::setMaxHops </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>max_hops</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Sets the max_hops to the given value This controls the maximum number of hops allowed between source and destination nodes Messages that are not delivered by the time their HOPS field exceeds max_hops on a routing node will be dropped and ignored. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">max_hops</td><td>The new value for max_hops </td></tr>
  </table>
  </dd>
</dl>

<p>References <a class="el" href="classRF22Router.html#ab6af5059286ee412f81f33c67ac95132">_max_hops</a>.</p>

</div>
</div>
<hr/><h2>Member Data Documentation</h2>
<a class="anchor" id="a27591173bc7e622beae9c247634b3dec"></a><!-- doxytag: member="RF22Router::_lastE2ESequenceNumber" ref="a27591173bc7e622beae9c247634b3dec" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t <a class="el" href="classRF22Router.html#a27591173bc7e622beae9c247634b3dec">RF22Router::_lastE2ESequenceNumber</a><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>The last end-to-end sequence number to be used Defaults to 0 </p>

<p>Referenced by <a class="el" href="classRF22Router.html#a43192f80e7d8f05844807b07f7d7bdf0">sendtoWait()</a>.</p>

</div>
</div>
<a class="anchor" id="ab6af5059286ee412f81f33c67ac95132"></a><!-- doxytag: member="RF22Router::_max_hops" ref="ab6af5059286ee412f81f33c67ac95132" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t <a class="el" href="classRF22Router.html#ab6af5059286ee412f81f33c67ac95132">RF22Router::_max_hops</a><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>The maximum number of hops permitted in routed messages. If a routed message would exceed this number of hops it is dropped and ignored. </p>

<p>Referenced by <a class="el" href="classRF22Router.html#ac6037c3300511d0277e42edea8ccf873">init()</a>, <a class="el" href="classRF22Mesh.html#a5702996188d7b3941a844fc4d39a6f57">RF22Mesh::recvfromAck()</a>, <a class="el" href="classRF22Router.html#abbb4344322693607d8a0be5f0f831015">recvfromAck()</a>, <a class="el" href="classRF22Router.html#a5e934a0ccc2d764ef0c0aa70a3d32cf9">RF22Router()</a>, and <a class="el" href="classRF22Router.html#a05f3bc34b320c05af36ad0f0f927bfa0">setMaxHops()</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="RF22Router_8h_source.html">RF22Router.h</a></li>
<li>RF22Router.cpp</li>
</ul>
</div>


<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
